<%@ page pageEncoding="UTF-8"%>
<%@ include file="/common/validate.jsp"%>
<%@ include file="function.jsp"%>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>通知中心</title>
    <link rel="stylesheet" href="/css/public.css?cache=<%=Math.random()%>">
    <link  href="../../hos_manage/images/favicon.ico?cache=<%=Math.random()%>" rel="shortcut icon" type="image/x-icon">
    <link rel="stylesheet" type="text/css" href="../../css/palace/message/message_center.css?a=<%=Math.random()%>">
    <script src="/js/jquery-1.9.1.min.js"></script>
</head>
<body id="app">
<%@ include file="../../header.jsp"%>
<!--内容-->
<div class="containerone">
    <%@ include file="../../left_menu.jsp"%>
    <!--右边内容-->
    <div class="right_cont">
        <!--右边导航下面内容-->
        <div class="address-book">
            <div class="title">
                <div class="address-left show-block note">
                    <span @click="homePage()" class="cursor-point">首页</span>
                    <span class="left-distance">></span>
                    <span class="left-distance">通知列表</span>
                </div>
                <div class="search-input-button">
                    <div class="create-member center" @click="levelDescribe()">通知级别</div>
                    <div class="title-right center" @click="sendMessage()">添加通知</div>
                </div>
            </div>
            <div class="container">
                <div class="position">
                    <div class="show-block address-book-right">
                        <div class="data-form show-margin-left line">
                            <div class="form-title">
                                <div class="show-block title-width-send center show-ver">发送人</div>
                                <div class="show-block title-width-title center show-ver">标题</div>
                                <div class="show-block title-width-compont center show-ver">回复数</div>
                                <div class="show-block title-width-kind center show-ver">类型</div>
                                <div class="show-block title-width-level center show-ver">级别</div>
                                <div class="show-block title-width-ready center show-ver">已读</div>
                                <div class="center show-block show-ver" style="width: 10%; height: 66px;line-height: 66px;">
                                    <div class="show-block title-width-unready unread">未读</div>
                                </div>
                            </div>
                            <div class="form-title bg-white line" v-for="i in messageList" @click="showMessageDetail(i.id)">
                                <div class="show-block title-width-send center show-ver" v-html="i.author"></div>
                                <div class="show-block title-width-title center show-ver" v-html="i.title"></div>
                                <div class="show-block title-width-compont center show-ver" v-html="i.comment"></div>
                                <div class="show-block title-width-kind center show-ver" v-html="i.category_name"></div>
                                <div class="show-block title-width-level center show-ver" v-html="i.level_name"></div>
                                <div class="show-block title-width-ready center show-ver" v-html="i.has_read"></div>
                                <div class="center show-block show-ver" style="width: 10%; height: 66px;line-height: 66px;">
                                    <div class="show-block title-width-unready unread" @click="showUnread(i.id)" v-html="i.no_read"></div>
                                </div>
                            </div>
                        </div>
                        <pagination :pagecount="page_count" :currentpage="current_page"></pagination>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<%@ include file="/components/pagination.jsp"%>
<script>
    new Vue({
        el: "#app",
        data: {
            messageList: [],
            page_count: 0,
            current_page: 1,
        },
        methods: {
            showUnread: function(obj) {
                saveParmsHerf("message_center", {
                    current_page: this.current_page,
                });
                locationHerf("unread_list", obj);
                event.stopPropagation();
            },
            getData: function() {
                var self = this;
                $.ajax({
                    type: "post",
                    url: "message_center.jsp",
                    data: {
                        act: "messgaeList",
                        hospital: "${user.hospital}",
                        pages: self.current_page + "",
                    },
                    success: function (res) {
                        res = JSON.parse(res);
                        self.messageList = res.data.list;
                        self.page_count = parseInt(res.data.count);
                    }
                });
            },
            levelDescribe: function () {
                locationHerf("level_describe");
            },
            sendMessage: function () {
                locationHerf("send_message");
            },
            showMessageDetail: function (obj) {
                saveParmsHerf("message_center", {
                    current_page: this.current_page,
                });
                locationHerf("message_detail", obj);
            },
            homePage: function () {
                location.href = "../../index.jsp";
            },
        },
        events: {
            changePage: function(i) {
                this.current_page = i.currentpage;
                this.getData();
            },
        },
        ready: function () {
            var params = getHrefParms("message_center");
            if (params) {
                this.current_page = params.current_page;
                clearHrefParms("message_center");
            }
            this.getData();
        },
        components: {
            pagination: pagination,
        },
    });
</script>
</html>
